using UnityEngine;

public class PlayerState_WallSlide : PlayerState
{
    public PlayerState_WallSlide(Player player, PlayerStateMachine stateMachine, string animBoolName) : base(player, stateMachine, animBoolName)
    {
    }


    public override void Enter()
    {
        base.Enter();
        player.movement.SetGravity(false);
    }

    public override void Exit()
    {
        base.Exit();
        player.movement.SetGravity(true);
    }

    public override void Update()
    {
        base.Update();
        player.movement.Climbing(-1);
        
        if (player.controller.wasJump())
        {
            stateMachine.ChangeState(player.WallJumpState);
            return;
        }

        if (MoveActionValue.x != 0 && MoveActionValue.x != player.controller.forward.x)
        {
            stateMachine.ChangeState(player.idleState);
            return;
        }

        if (!player.movement.IsWall())
        {
            stateMachine.ChangeState(player.idleState);
            return;
        }
        
        if (player.movement.IsGround())
        {
            stateMachine.ChangeState(player.idleState);
            return;
        }
        
    }
}
